package com.smart.draw.plantuml.common;

/**
 * @Author xiaoqiang
 * @Version PlantUmlType.java, v 0.1 2025年08月27日 00:06 xiaoqiang
 * @Description: plantuml类型枚举
 */
public enum PlantUmlType {

    SEQUENCE_DIAGRAM("sequence", "时序图",
            """
                    @startuml
                    participant User
                    User -> A: DoWork
                    activate A #FFBBBB
                    A -> A: Internal call
                    activate A #DarkSalmon
                    A -> B: << createRequest >>
                    activate B
                    B --> A: RequestCreated
                    deactivate B
                    deactivate A
                    A -> User: Done
                    deactivate A
                    participant Participant as Foo
                    actor       Actor       as Foo1
                    boundary    Boundary    as Foo2
                    control     Control     as Foo3
                    entity      Entity      as Foo4
                    database    Database    as Foo5
                    collections Collections as Foo6
                    queue       Queue       as Foo7
                    Foo -> Foo1 : To actor\s
                    Foo -> Foo2 : To boundary
                    Foo -> Foo3 : To control
                    Foo -> Foo4 : To entity
                    Foo -> Foo5 : To database
                    Foo -> Foo6 : To collections
                    Foo -> Foo7: To queue
                    @enduml
                    """),

    USE_CASE_DIAGRAM("use case", "用例图",
            """
                    @startuml
                    left to right direction
                    actor Guest as g
                    package Professional {
                      actor Chef as c
                      actor "Food Critic" as fc
                    }
                    package Restaurant {
                      usecase "Eat Food" as UC1
                      usecase "Pay for Food" as UC2
                      usecase "Drink" as UC3
                      usecase "Review" as UC4
                    }
                    fc --> UC4
                    g --> UC1
                    g --> UC2
                    g --> UC3
                    @enduml
                    
                    """),

    CLASS_DIAGRAM("class", "类图",
            """
                    @startuml
                    abstract        abstract
                    abstract class  "abstract class"
                    annotation      annotation
                    circle          circle
                    ()              circle_short_form
                    class           class
                    class           class_stereo  <<stereotype>>
                    diamond         diamond
                    <>              diamond_short_form
                    entity          entity
                    enum            enum
                    exception       exception
                    interface       interface
                    metaclass       metaclass
                    protocol        protocol
                    stereotype      stereotype
                    struct          struct
                    
                    Class01 <|-- Class02
                    Class03 *-- Class04
                    Class05 o-- Class06
                    Class07 .. Class08
                    Class09 -- Class10
                    
                    Class21 #-- Class22
                    Class23 x-- Class24
                    Class25 }-- Class26
                    Class27 +-- Class28
                    Class29 ^-- Class30
                    
                    Class11 <|.. Class12
                    Class13 --> Class14
                    Class15 ..> Class16
                    Class17 ..|> Class18
                    Class19 <--* Class20
                    
                    @enduml
                    
                    """),

    ACTIVITY_DIAGRAM("activity", "活动图",
            """
                    @startuml
                    !pragma useVerticalIf on
                    start
                    if (condition A) then (yes)
                      :Text 1;
                    elseif (condition B) then (yes)
                      :Text 2;
                      stop
                    elseif (condition C) then (yes)
                      :Text 3;
                    elseif (condition D) then (yes)
                      :Text 4;
                    else (nothing)
                      :Text else;
                    endif
     
                    start
                    switch (测试?)
                    case ( 条件 A )
                      :Text 1;
                    case ( 条件 B )\s
                      :Text 2;
                    case ( 条件 C )
                      :Text 3;
                    case ( 条件 D )
                      :Text 4;
                    case ( 条件 E )
                      :Text 5;
                    endswitch
                    stop
           
                    start
                    partition "**process** HelloWorld" {
                        note
                            This is my note
                            ----
                            //Creole test//
                        end note
                        :Ready;
                        :HelloWorld(i)>
                        :Hello-Sent;
                    }
                    stop
                    start
                    repeat
                      :测试某事;
                        if (发生错误?) then (没有)
                          #palegreen:好的;
                          break
                        endif
                        ->not ok;
                        :弹窗 "文本过长错误";
                    repeat while (某事发生文本过长错误?) is (是的) not (不是)
                    ->//合并步骤//;
                    :弹窗 "成功！";
                    stop
             
                    @enduml
                    
                    """),

    COMPONENT_DIAGRAM("component", "组件图",
            """
                    @startuml
                    
                    interface "Data Access" as DA
                    
                    DA - [First Component]
                    [First Component] ..> HTTP : use
                    
                    note left of HTTP : Web Service only
                    
                    note right of [First Component]
                      A note can also
                      be on several lines
                    end note
                    
                    @enduml
                    
                    """),

    STATE_DIAGRAM("state", "状态图",
            """
                    @startuml
                    scale 350 width
                    [*] --> NotShooting
                    
                    state NotShooting {
                      [*] --> Idle
                      Idle --> Configuring : EvConfig
                      Configuring --> Idle : EvConfig
                    }
                    
                    state Configuring {
                      [*] --> NewValueSelection
                      NewValueSelection --> NewValuePreview : EvNewValue
                      NewValuePreview --> NewValueSelection : EvNewValueRejected
                      NewValuePreview --> NewValueSelection : EvNewValueSaved
                    
                      state NewValuePreview {
                         State1 -> State2
                      }
                    
                    }
                    @enduml
                    
                    """),

    OBJECT_DIAGRAM("object", "对象图",
            """
                    @startuml
                    object Object01
                    object Object02
                    object Object03
                    object Object04
                    object Object05
                    object Object06
                    object Object07
                    object Object08
                    
                    Object01 <|-- Object02
                    Object03 *-- Object04
                    Object05 o-- "4" Object06
                    Object07 .. Object08 : some labels
                    
                    
                    object London
                    object Washington
                    object Berlin
                    object NewYork
                    
                    map CapitalCity {
                     UK *-> London
                     USA *--> Washington
                     Germany *---> Berlin
                    }
                    
                    NewYork --> CapitalCity::USA
                    @enduml
                    
                    """),

    DEPLOYMENT_DIAGRAM("deployment", "部署图",
            """
                    @startuml
                    actor actor
                    agent agent
                    artifact artifact
                    boundary boundary
                    card card
                    cloud cloud
                    component component
                    control control
                    database database
                    entity entity
                    file file
                    folder folder
                    frame frame
                    interface  interface
                    node node
                    package package
                    queue queue
                    stack stack
                    rectangle rectangle
                    storage storage
                    usecase usecase
                    
                    folder folder [
                    这是个 <b>文件夹
                    ----
                    您可以使用
                    ====
                    不同类型
                    ....
                    的分隔符
                    ]
                    
                    node node [
                    这是个 <b>结点
                    ----
                    您可以使用
                    ====
                    不同类型
                    ....
                    的分隔符
                    ]
                    
                    database database [
                    这是个 <b>数据库
                    ----
                    您可以使用
                    ====
                    不同类型
                    ....
                    的分隔符
                    ]
                    
                    usecase usecase [
                    这是个 <b>用例
                    ----
                    您可以使用
                    ====
                    不同类型
                    ....
                    的分隔符
                    ]
                    
                    actor foo1
                    actor foo2
                    foo1 <-0-> foo2
                    foo1 <-(0)-> foo2
                    
                    (ac1) -le(0)-> left1
                    ac1 -ri(0)-> right1
                    ac1 .up(0).> up1
                    ac1 ~up(0)~> up2
                    ac1 -do(0)-> down1
                    ac1 -do(0)-> down2
                    
                    actor1 -0)- actor2
                    
                    component comp1
                    component comp2
                    comp1 *-0)-+ comp2
                    [comp3] <-->> [comp4]
                    
                    boundary b1
                    control c1
                    b1 -(0)- c1
                    
                    component comp1
                    interface interf1
                    comp1 #~~( interf1
                    
                    :mode1actor: -0)- fooa1
                    :mode1actorl: -ri0)- foo1l
                    
                    [component1] 0)-(0-(0 [componentC]
                    () component3 )-0-(0 "foo" [componentC]
                    
                    [aze1] #-->> [aze2]
                    
                    
                    @enduml
                    
                    """),

    PACKAGE_DIAGRAM("package", "包图",
            """
                    @startuml
                    package com.example {
                      class ClassA
                      class ClassB
                    }
                    @enduml"""),

    TIMING_DIAGRAM("timing", "定时图",
            """
                    @startuml
                        robust "Web 浏览器" as WB
                        concise "Web 用户" as WU
                    
                        @0
                        WU is 空闲
                        WB is 空闲
                    
                        @100
                        WU is 等待中
                        WB is 处理中
                    
                        @300
                        WB is 等待中
                    
                        clock   "Clock_0"   as C0 with period 50
                        clock   "Clock_1"   as C1 with period 50 pulse 15 offset 10
                        binary  "Binary"  as B
                        concise "Concise" as C
                        robust  "Robust"  as R
                        analog  "Analog"  as A
                    
                    
                        @0
                        C is Idle
                        R is Idle
                        A is 0
                    
                        @100
                        B is high
                        C is Waiting
                        R is Processing
                        A is 3
                    
                        @300
                        R is Waiting
                        A is 1
                        clock clk with period 1
                        binary "enable" as EN
                        concise "dataBus" as db
                    
                        @0 as :start
                        @5 as :en_high\s
                        @10 as :en_low
                        @:en_high-2 as :en_highMinus2
                    
                        @:start
                        EN is low
                        db is "0x0000"
                    
                        @:en_high
                        EN is high
                    
                        @:en_low
                        EN is low
                    
                        @:en_highMinus2
                        db is "0xf23a"
                    
                        @:en_high+6
                        db is "0x0000"
                    @enduml
                    
                    """),

    REGEX_DIAGRAM("regex", "正则表达式图", """
            
            @startregex
            title specialEscapes
            \\t\\r\\n\\a\\e\\f
            
            !option useDescriptiveNames false
            
            \\d?\\D+\\w*\\W{1,2}|\\s.\\S
            @endregex
            
            
            """),

    NETWORK_DIAGRAM("network", "网络图",
            """
                    @startuml
                    nwdiag {
                      network Network {
                        Control     [shape = control]    \s
                        Database    [shape = database]   \s
                        Entity      [shape = entity]     \s
                        File        [shape = file]       \s
                        Folder      [shape = folder]     \s
                        Frame       [shape = frame]      \s
                        Hexagon     [shape = hexagon]    \s
                        Interface   [shape = interface]  \s
                      }
                    }
                    nwdiag {
                      network Network {
                        Label       [shape = label]      
                        Node        [shape = node]       
                        Package     [shape = package]    
                        Person      [shape = person]     
                        Queue       [shape = queue]      
                        Stack       [shape = stack]      
                        Rectangle   [shape = rectangle]  
                        Storage     [shape = storage]    
                        Usecase     [shape = usecase]    
                      }
                    }
                     nwdiag {
                       network NETWORK_BASE {
                        dev_A [address = "dev_A" ]
                        dev_B [address = "dev_B" ]
                       }
                       network IntNET1 {
                        dev_B [address = "dev_B1" ]
                        dev_M [address = "dev_M1" ]
                       }
                       network IntNET2 {
                        dev_B [address = "dev_B2" ]
                        dev_M [address = "dev_M2" ]
                      }
                     }
                    """),
    GANTT_DIAGRAM("gantt", "甘特图",
            """
                    @startgantt
                        [Prototype design] requires 15 days
                        [Test prototype] requires 10 days
                        [Test prototype] starts at [Prototype design]'s end
                    @endgantt
                    
                    
                    """),
    Chronology_DIAGRAM("chronology", "时间轴图",
            """
                    @startchronology
                        :2021-01-01: 项目开始
                        :2021-01-02: 需求分析
                        :2021-01-03: 设计文档
                        :2021-01-04: 编码
                        :2021-01-05: 测试
                        :2021-01-06: 发布
                        :2021-01-07: 结束
                    @endchronology
                    """),
    MINDMAP_DIAGRAM("mindmap", "思维导图",
            """
                    @startmindmap
                    * Root
                    ** Branch 1
                    *** Leaf 1
                    *** Leaf 2
                    ** Branch 2
                    
                    *[#Orange] root node
                     *[#lightgreen] some first level node
                      *[#FFBBCC] second level node
                      *[#lightblue] another second level node
                     *[#lightgreen] another first level node
                    
                     * root node
                     ** some first level node
                     ***_ second level node
                     ***_ another second level node
                     ***_ foo
                     ***_ bar
                     ***_ foobar
                     ** another first level node
                    
                     top to bottom direction
                     left side
                     * 1
                     ** 2
                     *** 4
                     *** 5
                     ** 3
                     *** 6
                     *** 7
                     <style>
                     node {
                         Padding 12
                         Margin 3
                         HorizontalAlignment center
                         LineColor blue
                         LineThickness 3.0
                         BackgroundColor gold
                         RoundCorner 40
                         MaximumWidth 100
                     }
                    
                     rootNode {
                         LineStyle 8.0;3.0
                         LineColor red
                         BackgroundColor white
                         LineThickness 1.0
                         RoundCorner 0
                         Shadowing 0.0
                     }
                    
                     leafNode {
                         LineColor gold
                         RoundCorner 0
                         Padding 3
                     }
                    
                     arrow {
                         LineStyle 4
                         LineThickness 0.5
                         LineColor green
                     }
                     </style>
                    
                     * Hi =)
                     ** sometimes i have node in wich i want to write a long text
                     *** this results in really huge diagram
                     **** of course, i can explicit split with a\\nnew line
                     **** but it could be cool if PlantUML was able to split long lines, maybe with an option\s
                    @endmindmap"""),

    ER_DIAGRAM("er", "实体关系图 (ER图)",
            """
                    @startuml
                    entity User {
                      *id : int
                      name : string
                    }
                    entity Order {
                      *id : int
                      user_id : int
                    }
                    User ||--o{ Order
                    @enduml"""),

    WIREFRAME_DIAGRAM("wireframe", "线框图 (UI原型)",
            """
                    @startsalt
                    {{^==Creole
                        This is **bold**
                        This is //italics//
                        This is ""monospaced""
                        This is --stricken-out--
                        This is __underlined__
                        This is ~~wave-underlined~~
                        --test Unicode and icons--
                        This is <U+221E> long
                        This is a <&code> icon
                        Use image : <img:https://plantuml.com/logo3.png>
                      }|
                      {^<b>HTML Creole\s
                       This is <b>bold</b>
                        This is <i>italics</i>
                        This is <font:monospaced>monospaced</font>
                        This is <s>stroked</s>
                        This is <u>underlined</u>
                        This is <w>waved</w>
                        This is <s:green>stroked</s>
                        This is <u:red>underlined</u>
                        This is <w:#0000FF>waved</w>
                        -- other examples --
                        This is <color:blue>Blue</color>
                        This is <back:orange>Orange background</back>
                        This is <size:20>big</size>
                      }|
                      {^Creole line
                      You can have horizontal line
                      ----
                      Or double line
                      ====
                      Or strong line
                      ____
                      Or dotted line
                      ..My title..
                      Or dotted title
                      //and title... //
                      ==Title==
                      Or double-line title
                      --Another title--
                      Or single-line title
                      Enjoy!
                      }|
                      {^Creole list item
                      **test list 1**
                      * Bullet list
                      * Second item
                      ** Sub item
                      *** Sub sub item
                      * Third item
                      ----
                      **test list 2**
                      # Numbered list
                      # Second item
                      ## Sub item
                      ## Another sub item
                      # Third item
                      }|
                      {^Mix on salt
                        ==<color:Blue>Just plain text
                        [This is my default button]
                        [<b><color:green>This is my green button]
                        [ ---<color:#9a9a9a>This is my disabled button-- ]
                        []  <size:20><color:red>Unchecked box
                        [X] <color:green>Checked box
                        "//Enter text here//   "
                        ^This is a droplist^
                        ^<color:#9a9a9a>This is a disabled droplist^
                        ^<b><color:red>This is a red droplist^
                      }}
                    @endsalt
                    
                    """),

    WBS_DIAGRAM("wbs", "工作分解结构图 (WBS图)",
            """
                    @startwbs
                    
                    * WBS
                    ** Task 1
                    *** Sub-task 1
                    *** Sub-task 2
                    ** Task 2
                    *** Sub-task 1
                    *** Sub-task 2
                    
                    @endwbs
                    """),

    ENBF_DIAGRAM("enbf", "EBNF 图",
            """
                    @startebnf
                    title All EBNF elements managed by PlantUML
                    
                    (* Nodes *)
                    litteral = "a";
                    special = ? a ?;
                    rule = a;
                    
                    (* Edges *)
                    required = a;
                    optional = [a];
                    
                    zero_or_more = {a};
                    one_or_more = a, {a};
                    one_or_more_ebnf = {a}-;
                    
                    zero_or_more_with_separator = [a, {',', a}];
                    one_or_more_with_separator = a, {',', a};
                    zero_or_more_with_terminator = {a, ','};
                    one_or_more_with_terminator = a, ',', {a, ','};
                    one_or_more_with_terminator_ebnf = {a, ','}-;
                    
                    alternative = a | b;
                    group = (a | b) , c;
                    without_group = a | b , c;
                    @endebnf
                    """
    ),
    ARCHIMATE_DIAGRAM("archimate", "Archimate 图",
            """
                    @startuml
                    
                        skinparam rectangle<<behavior>> {
                            roundCorner 25
                        }
                        sprite $bProcess jar:archimate/business-process
                        sprite $aService jar:archimate/application-service
                        sprite $aComponent jar:archimate/application-component
                    
                        rectangle "Handle claim"  as HC <<$bProcess>><<behavior>> #Business
                        rectangle "Capture Information"  as CI <<$bProcess>><<behavior>> #Business
                        rectangle "Notify\\nAdditional Stakeholders" as NAS <<$bProcess>><<behavior>> #Business
                        rectangle "Validate" as V <<$bProcess>><<behavior>> #Business
                        rectangle "Investigate" as I <<$bProcess>><<behavior>> #Business
                        rectangle "Pay" as P <<$bProcess>><<behavior>> #Business
                    
                        HC *-down- CI
                        HC *-down- NAS
                        HC *-down- V
                        HC *-down- I
                        HC *-down- P
                    
                        CI -right->> NAS
                        NAS -right->> V
                        V -right->> I
                        I -right->> P
                    
                        rectangle "Scanning" as scanning <<$aService>><<behavior>> #Application
                        rectangle "Customer admnistration" as customerAdministration <<$aService>><<behavior>> #Application
                        rectangle "Claims admnistration" as claimsAdministration <<$aService>><<behavior>> #Application
                        rectangle Printing <<$aService>><<behavior>> #Application
                        rectangle Payment <<$aService>><<behavior>> #Application
                    
                        scanning -up-> CI
                        customerAdministration  -up-> CI
                        claimsAdministration -up-> NAS
                        claimsAdministration -up-> V
                        claimsAdministration -up-> I
                        Payment -up-> P
                    
                        Printing -up-> V
                        Printing -up-> P
                    
                        rectangle "Document\\nManagement\\nSystem" as DMS <<$aComponent>> #Application
                        rectangle "General\\nCRM\\nSystem" as CRM <<$aComponent>>  #Application
                        rectangle "Home & Away\\nPolicy\\nAdministration" as HAPA <<$aComponent>> #Application
                        rectangle "Home & Away\\nFinancial\\nAdministration" as HFPA <<$aComponent>>  #Application
                    
                        DMS .up.|> scanning
                        DMS .up.|> Printing
                        CRM .up.|> customerAdministration
                        HAPA .up.|> claimsAdministration
                        HFPA .up.|> Payment
                    
                        legend left
                        Example from the "Archisurance case study" (OpenGroup).
                        See
                        ====
                        <$bProcess> :business process
                        ====
                        <$aService> : application service
                        ====
                        <$aComponent> : application component
                        endlegend
                    @enduml
                    """),

    JSON_DIAGRAM("json", "JSON 结构图",
            """
                    @startjson
                    {
                      "firstName": "John",
                      "lastName": "Smith",
                      "isAlive": true,
                      "age": 27,
                      "address": {
                        "streetAddress": "21 2nd Street",
                        "city": "New York",
                        "state": "NY",
                        "postalCode": "10021-3100"
                      },
                      "phoneNumbers": [
                        {
                          "type": "home",
                          "number": "212 555-1234"
                        },
                        {
                          "type": "office",
                          "number": "646 555-4567"
                        }
                      ],
                      "children": [],
                      "spouse": null
                    }
                    @endjson
                    """),

    YAML_DIAGRAM("yaml", "YAML 结构图",
            """
                    @startyaml
                    <style>
                    yamlDiagram {
                        highlight {
                          BackGroundColor red
                          FontColor white
                          FontStyle italic
                        }
                    }
                    </style>
                    #highlight "french-hens"
                    #highlight "xmas-fifth-day" / "partridges"
                    
                    doe: "a deer, a female deer"
                    ray: "a drop of golden sun"
                    pi: 3.14159
                    xmas: true
                    french-hens: 3
                    calling-birds:\s
                    	- huey
                    	- dewey
                    	- louie
                    	- fred
                    xmas-fifth-day:\s
                    	calling-birds: four
                    	french-hens: 3
                    	golden-rings: 5
                    	partridges:\s
                    		count: 1
                    		location: "a pear tree"
                    	turtle-doves: two
                    @endyaml
                    
                    """),

    DOT_DIAGRAM("dot", "Graphviz DOT 图",
            """
                    @startdot
                    digraph G {
                      A -> B;
                      B -> C;
                    }
                    @enddot"""),

    DITAA_DIAGRAM("ditaa", "ASCII 艺术图 (Ditaa)",
            """
                    @startditaa
                    +--------+
                    | Text   |
                    +--------+
                    @endditaa"""),

    SALT_DIAGRAM("salt", "Salt UI 图",
            """
                    @startsalt
                    {
                      Login
                      "User:"
                      +TextField
                      "Password:"
                      +PasswordField
                      [Cancel][OK]
                    }
                    @endsalt"""),

    SVG_DIAGRAM("svg", "SVG 图",
            """
                    @startsvg
                    <svg width="100" height="100">
                      <circle cx="50" cy="50" r="40" />
                    </svg>
                    @endsvg"""),

    C4_DIAGRAM("c4", "C4 模型图",
            """
                    @startuml
                    !includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
                    Person(user, "User")
                    System_Boundary(system, "System") {
                      Container(web_app, "Web Application", "Java")
                    }
                    Rel(user, web_app, "Uses")
                    @enduml""");

    private final String type;
    private final String desc;
    private final String example;

    PlantUmlType(String type, String desc, String example) {
        this.type = type;
        this.desc = desc;
        this.example = example;
    }

    public String getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public String getExample() {
        return example;
    }

    public static PlantUmlType getByType(String type) {
        for (PlantUmlType value : values()) {
            if (value.type.equals(type)) {
                return value;
            }
        }
        return SEQUENCE_DIAGRAM;
    }

    public static boolean isNonUmlType(PlantUmlType type) {
        return switch (type) {
            case GANTT_DIAGRAM, MINDMAP_DIAGRAM, WIREFRAME_DIAGRAM, JSON_DIAGRAM,
                 YAML_DIAGRAM, DOT_DIAGRAM, DITAA_DIAGRAM, SALT_DIAGRAM, SVG_DIAGRAM,
                 C4_DIAGRAM -> true;
            default -> false;
        };
    }
}